package logic

import (
	"context"
	"errors"
	"video-hub/models/mysql"

	"video-hub/videorpc/internal/svc"
	"video-hub/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type MenDelLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewMenDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MenDelLogic {
	return &MenDelLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *MenDelLogic) MenDel(in *videorpc.MenDelRequest) (*videorpc.MenDelResponse, error) {
	// todo: add your logic here and delete this line
	var men mysql.Comment

	if err := men.FindMenId(mysql.DB, in.CommentId); err != nil {
		return nil, errors.New("评论id不存在")
	}
	if err := men.DelMen(mysql.DB, in.CommentId); err != nil {
		return nil, err
	}
	return &videorpc.MenDelResponse{}, nil
}
